<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>login</title>
    <!--在本服务中自己调用-->
    <!--<script src="jquery.js"></script>
    <script>
        $(function () {
            $("#btn").click(function () {
                $.ajax({
                    url:"http://localhost:8818/login",
                    data:{
                      UserName:$("#username").val(),
                      PassWord:$("#password").val()
                    },
                    success:function (data) {
                        alert(data.data);
                        if(data.data === null || data.data === ""){
                            location.href = "/login.html"
                        }else{
                            location.href = "/index.html"
                        }
                    }
                });
            });
        })
    </script>-->
    <!--通过网关调用-->
    <script src="/auth/jquery.js"></script>
    <script>
        $(function () {
            $("#btn").click(function () {
                $.ajax({
                    url:"http://localhost:8898/auth/login",
                    data:{
                      UserName:$("#username").val(),
                      PassWord:$("#password").val()
                    },
                    success:function (data) {
                        if(data.statusCode === 401){
                            alert("登录失败");
                            location.href = "/auth/login.html"
                        }else{
                            var storage =  window.localStorage;
                            storage.setItem("token",data.data);
                            location.href = "/auth/index.html"
                        }
                    }
                });
            });
        })
    </script>
</head>
<body>
<p>login</p>
 <form>
     用户名：<input id="username" type="text" name="username" /><br />
     密&nbsp;码：  <input id="password" type="text" name="password" /><br />
               <input id="btn" type="button" value="登录" /><br>
 </form>
</body>
</html>